import { defineStore } from 'pinia'
import loginApi from '@/api/modules/login'
import { localStorage } from 'mp-storage'
import type { LoginForm, LoginType } from '@/types/login'
export const useLoginStore = defineStore('login', {
  state: () => ({
    // 保存用户信息
    userInfo: null as any,
  }),
  actions: {
    // 发起登陆请求
    async login(data: LoginForm) {
      this.userInfo = await loginApi.login(data)
    },
  },
  persist: {
    storage: localStorage,
    paths: ['userInfo'],
  },
})
